package gui.obu;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

import com.swtdesigner.SWTResourceManager;

public class ObuWelcomePanelImpl extends AbstractObuPanelImpl implements ObuWelcomePanel {

	Label welcome;
	Label fingerInst;
	Button newUserButton;
	Label newUserInst;
	Button fingerprint;
	
	public ObuWelcomePanelImpl(Display display, Shell shell) {
		super(display, shell);
	}

	/**
	 * @wbp.parser.entryPoint
	 */
	public void open() {
		// Remove at compile time
//		shell = new Shell();
		// **********************
		
		shell.setSize(450, 300);
		shell.setText("SWT Application");
		
		welcome = new Label(shell, SWT.CENTER);
		welcome.setBounds(118, 10, 181, 40);
		welcome.setText("Welcome to the Defensive Driver!");
		welcome.setFont(new Font(display, "Arial", 12, SWT.ITALIC|SWT.BOLD));
		
		fingerInst = new Label(shell, SWT.CENTER);
		fingerInst.setBounds(108, 56, 203, 45);
		fingerInst.setText("Please Swipe Your Finger\nAlong the Reader to Log-In");
		fingerInst.setFont(new Font(display, "Arial", 12, SWT.ITALIC));
		
		newUserButton = new Button(shell, SWT.NONE);
		newUserButton.setBounds(178, 229, 75, 25);
		newUserButton.setText("New User");
		newUserButton.addListener(SWT.Selection, new Listener() {

			@Override
			public void handleEvent(Event event) {
				ObuNewUserPanel window = new ObuNewUserPanelImpl(display, shell);
				dispose();
				window.open();
			}
			
		});
		
		newUserInst = new Label(shell, SWT.NONE);
		newUserInst.setBounds(159, 198, 113, 25);
		newUserInst.setText("For New Users:");
		newUserInst.setFont(new Font(display, "Arial", 12, SWT.ITALIC));
		
		fingerprint = new Button(shell, SWT.NONE);
		fingerprint.setImage(SWTResourceManager.getImage(ObuWelcomePanelImpl.class, "/images/fingerprint.gif"));
		fingerprint.setBounds(174, 107, 69, 85);
		fingerprint.addListener(SWT.Selection, new Listener() {
			@Override
			public void handleEvent(Event event) {
				ObuDrivingDisplayPanel window = new ObuDrivingDisplayPanelImpl(display, shell);
				// TODO: Send info to DB
				dispose();
				window.open();
			}
		});

		shell.open();
		shell.layout();
	}
}
